package ink.lovejinhu.swardToOffer;

import java.util.HashMap;

/**
 * @author jinhu
 * created 2021-08-16 17:18
 */
public class Offer_046 {
    /**
     * 把数字翻译成字符串
     * <p>
     * 以i结尾的数字，翻译英文为f(i)
     * f(i)  = f(i-1)+num[i]   ||  f(i-2)+num[i-1]num[i-2]
     *
     * @param num
     * @return
     */
    public int translateNum(int num) {
        HashMap<String, Character> dic = new HashMap<>();
        for (int i = 0; i < 26; i++) {
            dic.put(i + "", (char) ('a' + i));
        }
        String numString = num + "";
        int[] ints = new int[numString.length()+1];
        ints[0] = 1;
        ints[1] = 1;
        for (int i = 2; i <= numString.length(); i++) {
            String substring = numString.substring(i - 2, i );
            if (substring.compareTo("25") <= 0 && substring.compareTo("10") >= 0) {
                ints[i] = ints[i - 1] + ints[i - 2];
            } else {
                ints[i] = ints[i - 1];
            }

        }


        return ints[ints.length - 1];
    }

    public static void main(String[] args) {

    }
}
